/**
 * @file:__builtin_return_address.c
 * @brief:使用__builtin_return_address()函数，打印函数调用信息
 * @author:liaowx
 * @date:2019.08.02
 */
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
 
#define MAX_LEVEL 4
void sigfunc(int signo)
{
    printf("%s(0): %p\n", __func__, __builtin_return_address(0));
    exit(1);
}
 
int b()
{
    printf("%s(0): %p\n", __func__, __builtin_return_address(0));
    printf("%s(1): %p\n", __func__, __builtin_return_address(1));
    while(1) {
        sleep(1);
    }
}

int a(int temp)
{
    temp += 1;
    printf("%s(0): %p\n", __func__, __builtin_return_address(0));
 
    b();
 
    return temp;
}
